package com.zyong.design.pattern.memento.case3;

import java.util.HashMap;
import java.util.Map;

/**
 * @program: zyong-design-pattern
 * @ClassName: Caretaker
 * @author: zyong
 * @create: 2024-05-12 23:38
 */
public class Caretaker {
    private int index = 1;
    private Map<Integer, Memento> mementos = new HashMap<Integer, Memento>();

    public void add(Memento memento) {
        mementos.put(index++, memento);
    }

    public Memento get(int index) {
        return mementos.get(index);
    }

    public void remove() {
        mementos.clear();
    }
}
